﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Super_Pong
{
    public class Bar : Entity
    {
        int points;

        public Bar() { }

        public Bar(ContentManager content, GameWindow window, String texture_asset_name, String left_or_right, Vector2 initialSpeed)
        {
            setTexture(content.Load<Texture2D>(texture_asset_name));
            if (left_or_right == "left")
                {
                    setPos(new Vector2(0, window.ClientBounds.Height / 2 - getTexture().Height / 2));
                }
            if (left_or_right == "right")
                {
                    setPos(new Vector2(window.ClientBounds.Width - getTexture().Width, window.ClientBounds.Height / 2 - getTexture().Height / 2));
                }
            setSpd(initialSpeed);
        }

        public BoundingBox barCollisionArea()
        {
            return new BoundingBox(
                new Vector3(getPos().X, getPos().Y, 0.0f),
                new Vector3(
                    getPos().X + getTexture().Width,
                    getPos().Y + getTexture().Height,
                    0)
                    );
        }

        public void positionLimit(GameWindow window)
        {
            if (getPos().Y <= 0)
                setPos(new Vector2(getPos().X, 0));
            if (getPos().Y >= window.ClientBounds.Height - getTexture().Height)
                setPos(new Vector2(getPos().X, window.ClientBounds.Height - getTexture().Height));
        }

        public int getPoints()
        {
            return points;
        }

        public void setPoints(int value)
        {
            points += value;
        }

        public void drawPoints(GameWindow window, SpriteBatch spriteBatch, SpriteFont font,String side)
        {             
            if (side == "right")     
                spriteBatch.DrawString(font,getPoints().ToString(), new Vector2((window.ClientBounds.Width/2)+20, 10), Color.White);
            else
                spriteBatch.DrawString(font,getPoints().ToString(), new Vector2((window.ClientBounds.Width/2)-35, 10), Color.White);
            

        }
        //Adicionado por Lucas
        //modified by Yamanaka
        public void update(GameTime time, GameWindow window) { }
    }
}
